Text-to-Speech API
Endpoint /tts
https://api.botlhale.xyz/tts
You need to include an
Authentication Token
in request headers. See the Authentication page of this documentation for information on how to generate authentication token codes.
Method: POST
This endpoint handles Text-to-Speech (TTS) requests by converting input text into synthesized speech. The request is processed by an external TTS service, and the response includes a URL to the generated audio file along with the sampling rate.
Authentication
A valid Bearer token must be included in the request headers.
Headers:
- Authorization: Bearer
<your_token>
Form Arguments
Request Params | Data Type | Description | |
---|---|---|---|
text | string | Required | The text to be converted into speech. |
language_code | string | Required | The language code specifying the language for speech synthesis |
Response body
The API returns a JSON object containing the audio URL and additional details about the request.#
Example Response:
Unset
{
"audio_url": "https://s3-bucket-url.com/tts/audio_123456.mp3",
"language_code": "en-US",
"text": "Hello, how are you?",
"sampling_rate": 22050,
"date_received": "2025-01-28T10:00:00Z"
}
Response Fields:
Request Params | Data Type | Description |
---|---|---|
audio_ur | string | The URL where the synthesized speech file can be accessed. |
language_code | string | The language code used for synthesis. |
text | string | The original input text. |
sampling_rate | string | The sample rate of the generated audio in hertz. |
date_received | string | The date and time when the request was processed, in ISO 8601 format. |
Supported Languages
The following table shows the languages Botlhale AI currently supports. The table also indicates the speech tasks supported for each language. Our team is always working to add new languages to the list.
Language | Region | Code | Translation | ASR | TTS | Diarization | Language ID |
---|---|---|---|---|---|---|---|
English | South Africa | en-ZA | √ | √ | √ | √ | √ |
isiZulu | South Africa | zu-ZA | √ | √ | √ | √ | √ |
isiXhosa | South Africa | xh-ZA | √ | √ | √ | √ | √ |
Sesotho | South Africa | st-ZA | √ | √ | - | √ | √ |
Setswana | South Africa | tn-ZA | √ | √ | √ | √ | √ |
Sepedi | South Africa | nso-ZA | √ | √ | √ | √ | √ |
Tshivenda | South Africa | vr-ZA | - | √ | √ | √ | √ |
Xitsonga | South Africa | ts-ZA | √ | √ | - | √ | √ |
Afrikaans | South Africa | af-ZA | √ | √ | √ | √ | √ |
Kiswahili | Kenya | sw-KE | √ | √ | √ | √ | - |
Kinyarwanda | Rwanda | rw-RW | √ | √ | - | - | - |
Request Example
- Python
- Bash
- JavaScript
- NodeJs - Request
import requests
url = "https://api-dev.botlhale.xyz/tts"
payload = {'LanguageCode': 'xh-ZA',
'text_msg': 'Xa ufuna ukuthenga imoto cofa iqhosha lokuqala.'}
files=[
]
headers = {}
response = requests.request("POST", url, headers=headers, data=payload, files=files)
print(response.text)
curl --location 'https://api-dev.botlhale.xyz/tts' \
--form 'language_code="xh-ZA"' \
--form 'text_msg="Xa ufuna ukuthenga imoto cofa iqhosha lokuqala."'
const formdata = new FormData();
formdata.append("language_code", "xh-ZA");
formdata.append("text_msg", "Xa ufuna ukuthenga imoto cofa iqhosha lokuqala.");
const requestOptions = {
method: "POST",
body: formdata,
redirect: "follow"
};
fetch("https://api-dev.botlhale.xyz/tts", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api-dev.botlhale.xyz/tts',
'headers': {
},
formData: {
'language_code': 'xh-ZA',
'text_msg': 'Xa ufuna ukuthenga imoto cofa iqhosha lokuqala.'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Response body
{
"date_received": "09/03/2023 11:18:09",
"language_code": "IsiXhosa",
"speech_responseURL": "<SpeechResponseURL>",
"text_msg": "Xa ufuna ukuthenga imoto cofa iqhosha lokuqala."
}
Contact us
We are here to help! Please contact us with any questions.